<?php /*a:1:{s:52:"D:\crm\application\crm\view\product\course\edit.html";i:1670547849;}*/ ?>
<?php 
$list = model('product.course')->where('id',$_GET['id'])->find();
?>
<!DOCTYPE html>
<html>

<head>
    <meta charset="utf-8">
    <title>layui</title>
    <meta name="renderer" content="webkit">
    <meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
    <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1">
    <link rel="stylesheet" href="/static/crm/lib/layui-v2.6.3/css/layui.css" media="all">
    <link rel="stylesheet" href="/static/crm/css/public.css" media="all">
    <style>
        body {
            background-color: #ffffff;
        }
    </style>
</head>

<body>
    <div class="layui-form layuimini-form">
        <form class="layui-form" lay-filter="formTest">
            <!-- 获取修改id -->
            <input type="hidden" name="id" value="<?php echo htmlentities($list['id']); ?>">

            <div class="layui-form-item">
                <label class="layui-form-label">课程名称：</label>
                <div class="layui-input-block">
                    <input type="text" name="name" value="" class="layui-input field-name" placeholder="请输入课程名称">
                    <!-- <tip>填写课程名称。</tip> -->
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">价格：</label>
                <div class="layui-input-block">
                    <input type="text" name="price" value="" class="layui-input field-price" placeholder="请输入价格">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">单位：</label>
                <div class="layui-input-block">
                    <div class="layui-input-inline" style="width: 100%;">
                        <select name="unit" class="field-unit">
                            <option value="0" >年</option>
                            <option value="1" >季</option>
                            <option value="2" >月</option>
                            <option value="3" >周</option>
                            <option value="4" >天</option>
                            <option value="5" >课时</option>
                            <option value="6" >学期</option>
                        </select>
                    </div>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">课时：</label>
                <div class="layui-input-block">
                    <input type="number" name="minute_hour" value="" class="layui-input field-minute_hour"  placeholder="请输入课时">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">校区：</label>
                <div class="layui-input-block">
                    <div class="layui-input-inline" style="width: 84%;">
                        <select name="campus_id"  class="field-campus_id">
                            <option value="">请选择校区</option>
                            <?php if(is_array($campusList) || $campusList instanceof \think\Collection || $campusList instanceof \think\Paginator): $i = 0; $__LIST__ = $campusList;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$campus): $mod = ($i % 2 );++$i;?>
                            <option value="<?php echo htmlentities($campus['id']); ?>"><?php echo htmlentities($campus['name']); ?></option>
                            <?php endforeach; endif; else: echo "" ;endif; ?>
                        </select>
                    </div>
                    <button type="button" class="layui-btn" style="background-color: #393D49; float: right;"
                        data-url="/crm/product.campus/add" data-title="添加校区" lay-submit lay-filter="campusAdd"><i
                            class="fa fa-plus"></i> 添加校区</button>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">专业：</label>
                <div class="layui-input-block">
                    <div class="layui-input-inline" style="width: 84%;">
                        <select name="major_id" lay-search="" class="field-major_id">
                            <option value="">请选择专业</option>
                            <?php if(is_array($majorList) || $majorList instanceof \think\Collection || $majorList instanceof \think\Paginator): $i = 0; $__LIST__ = $majorList;if( count($__LIST__)==0 ) : echo "" ;else: foreach($__LIST__ as $key=>$major): $mod = ($i % 2 );++$i;?>
                            <option value="<?php echo htmlentities($major['id']); ?>"><?php echo htmlentities($major['name']); ?></option>
                            <?php endforeach; endif; else: echo "" ;endif; ?>
                        </select>
                    </div>
                    <button type="button" class="layui-btn" style="background-color: #393D49; float: right;"
                        data-url="/crm/product.major/add" data-title="添加专业" lay-submit lay-filter="majorAdd"><i
                            class="fa fa-plus"></i> 添加专业</button>
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">紧急联系人：</label>
                <div class="layui-input-block">
                    <input type="radio" name="has_phone_too" class="field-has_phone_too" value="0" title="不需要">
                    <input type="radio" name="has_phone_too" class="field-has_phone_too" value="1" title="需要">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">状态：</label>
                <div class="layui-input-block">
                    <input type="radio" name="status" value="1" title="启用" class="field-status">
                    <input type="radio" name="status" value="0" title="禁用" class="field-status">
                </div>
            </div>
            <div class="layui-form-item">
                <label class="layui-form-label">排序：</label>
                <div class="layui-input-block">
                    <input type="number" name="sort" value="" class="layui-input field-sort">
                </div>
            </div>

            <div class="layui-form-item">
                <div class="layui-input-block">
                    <button class="layui-btn layui-btn-normal" lay-submit lay-filter="saveBtn">确认保存</button>
                    <button type="reset" class="layui-btn layui-btn-primary">重置</button>
                </div>
            </div>
        </form>
    </div>
    <script src="/static/crm/lib/layui-v2.6.3/layui.js" charset="utf-8"></script>
    <script>
        // 扩展模块  config的设置是全局的
        layui.config({
            base: '/static/crm/js/modules/' //假设这是你存放拓展模块的根目录
        });

        layui.use(['form', 'jquery', 'layer', 'func'], function () {
            var form = layui.form,
                layer = layui.layer,
                $ = layui.jquery;

            layui.func.assign(<?= json_encode($list) ?>);   // 解析数据
            form.val("formTest", { //formTest 即 class="layui-form" 所在元素属性 lay-filter="" 对应的值
                // 
            });

            //监听提交
            form.on('submit(saveBtn)', function (data) {
                $.ajax({
                    url: '/crm/product.course/updateData',
                    type: 'POST',
                    dataType: 'json',
                    data: data.field,
                    // data: JSON.stringify(data.field),
                    success: function (res) {
                        if (res.code == 1) {
                            layer.msg(res.msg, {
                                time: 3000,
                                end: function () {
                                    window.parent.location.reload();
                                }
                            });
                        }
                        layer.msg(res.msg);
                    }
                })
                return false;
            });

        });
    </script>
</body>

</html>